package o;

import android.text.TextUtils;
import android.util.Log;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public abstract class dob {
    private static final String ˎ = dob.class.getSimpleName();

    public static Field[] ˊ(Class cls) {
        Object obj = null;
        if (cls.getSuperclass() != null) {
            obj = ˊ(cls.getSuperclass());
        }
        Object declaredFields = cls.getDeclaredFields();
        if (obj == null || obj.length <= 0) {
            obj = declaredFields;
        } else {
            Object obj2 = new Field[(declaredFields.length + obj.length)];
            System.arraycopy(obj, 0, obj2, 0, obj.length);
            System.arraycopy(declaredFields, 0, obj2, obj.length, declaredFields.length);
            Field[] fieldArr = obj2;
        }
        List arrayList = new ArrayList();
        for (Field field : fieldArr) {
            if (field.getName().indexOf("$") < 0) {
                arrayList.add(field);
            }
        }
        if (arrayList.size() == fieldArr.length) {
            return fieldArr;
        }
        fieldArr = new Field[arrayList.size()];
        arrayList.toArray(fieldArr);
        return fieldArr;
    }

    public static Class ˎ(Field field) {
        if (Map.class.isAssignableFrom(field.getType())) {
            return ˋ(field, 1);
        }
        if (List.class.isAssignableFrom(field.getType())) {
            return ˋ(field, 0);
        }
        return null;
    }

    private static Class ˋ(Field field, int i) {
        Type genericType = field.getGenericType();
        if (genericType instanceof ParameterizedType) {
            Type[] actualTypeArguments = ((ParameterizedType) genericType).getActualTypeArguments();
            if (actualTypeArguments != null && actualTypeArguments.length > i) {
                try {
                    if (actualTypeArguments[i] instanceof Class) {
                        return (Class) actualTypeArguments[i];
                    }
                    int i2;
                    String obj = actualTypeArguments[i].toString();
                    int indexOf = obj.indexOf("class ");
                    if (indexOf < 0) {
                        i2 = 0;
                    } else {
                        i2 = indexOf;
                    }
                    indexOf = obj.indexOf("<");
                    if (indexOf < 0) {
                        indexOf = obj.length();
                    }
                    return Class.forName(obj.substring(i2, indexOf));
                } catch (ClassNotFoundException e) {
                    Logger.e(ˎ, "getType exception!" + e.getMessage());
                }
            }
        }
        return null;
    }

    public static Method ˏ(Class<?> cls, String str, Class<?>... clsArr) {
        Method method = null;
        if (!(cls == null || TextUtils.isEmpty(str))) {
            try {
                method = cls.getMethod(str, clsArr);
            } catch (NoSuchMethodException e) {
                Log.e(ˎ, "Not such method:" + str + e.getMessage());
            }
        }
        return method;
    }
}
